package com.readaloud.hibernate.user;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

//@Entity

public class Books_old {/*

	@Id @GeneratedValue
	private int bookid;
	private String bookName;
	
	@OneToMany(mappedBy = "books",cascade= CascadeType.ALL)
	@NotFound(action = NotFoundAction.IGNORE)
	private Collection<Comment> comment = new ArrayList<Comment>();

	@ManyToMany
	@NotFound(action = NotFoundAction.IGNORE)
	private Collection<Author> authorList = new ArrayList<Author>();
	
	@ManyToMany
	@NotFound(action = NotFoundAction.IGNORE)
	private Collection<Reader> readerList = new ArrayList<Reader>();
	
	private String title;
	private String bookAuthor;
	private String releaseDate;
	private String language;
	
	public int getBookid() {
		return bookid;
	}

	public void setBookid(int bookid) {
		this.bookid = bookid;
	}

	public String getBookName() {
		return bookName;
	}

	public void setBookName(String bookName) {
		this.bookName = bookName;
	}

	public Collection<Comment> getComment() {
		return comment;
	}

	public void setComment(Collection<Comment> comment) {
		this.comment = comment;
	}

	public Collection<Author> getAuthorList() {
		return authorList;
	}

	public void setAuthorList(Collection<Author> authorList) {
		this.authorList = authorList;
	}

	public Collection<Reader> getReaderList() {
		return readerList;
	}

	public void setReaderList(Collection<Reader> readerList) {
		this.readerList = readerList;
	}

	
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}


	public String getBookAuthor() {
		return bookAuthor;
	}

	public void setBookAuthor(String bookAuthor) {
		this.bookAuthor = bookAuthor;
	}

	public String getReleaseDate() {
		return releaseDate;
	}

	public void setReleaseDate(String releaseDate) {
		this.releaseDate = releaseDate;
	}

	public String getLanguage() {
		return language;
	}

	public void setLanguage(String language) {
		this.language = language;
	}

	//function to parse book for details
	public void parsebook(String filepath)
	{
		FileInputStream fstream;
		try {
			fstream = new FileInputStream(filepath);

			DataInputStream in = new DataInputStream(fstream);
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			String strLine;
			String[] temp = null;
			
			while ((strLine = br.readLine()) != null) {

				if (strLine.contains("Title:")) {
					temp = strLine.split(":");
					strLine = temp[1].trim();
					//set in object value setTitle();
					
					System.out.println("T->" + strLine);
					this.setTitle(strLine);
					temp = null;
				}
				if (strLine.contains("Author:")) {
					temp = strLine.split(":");
					strLine = temp[1].trim();
					// set in object to persist
					System.out.println("A->" + strLine);
					this.setBookAuthor(strLine);
					temp = null;
				}
				
				if (strLine.contains("Release Date:")) {
					temp = strLine.split(":");
					strLine = temp[1].trim();
					//System.out.println("temp check" + strLine);
					temp = strLine.split("\\[");
					strLine = temp[0].trim();

					//set object
					System.out.println("R->" + strLine);
					this.setReleaseDate(strLine);
					temp = null;
				}
				
				if (strLine.contains("Language:")) {
					temp = strLine.split(":");
					strLine = temp[1].trim();
					
					//set object
					System.out.println("L->" + strLine);
					this.setLanguage(strLine);
					temp = null;
					break;
				}

			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally
		{
			if(obj.getfield is null)
				set that object field to "data not available"
				
				and then persist
		}

	}

	
*/}
